home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / linux-image-3.2.0-4-486.preinst < prev    next >
Encoding:
Text File  |  2012-12-19  |  3.0 KB  |  125 lines

  1. #! /usr/bin/perl
  2. #
  3. use strict;
  4. use warnings;
  5.  
  6. use Debconf::Client::ConfModule qw(:all);
  7. version('2.0');
  8. my $capb=capb("backup");
  9.  
  10. $|=1;
  11.  
  12. # Predefined values:
  13. my $version         = "3.2.0-4-486";
  14. my $kimage          = "vmlinuz";
  15. my $preinst_hook    = '';       #Normally we do not
  16. my $kernel_arch       = "x86";
  17. my $package_name    = "linux-image-$version";
  18.  
  19. #known variables
  20. my $realimageloc    = "/boot/";
  21. my $CONF_LOC        = '/etc/kernel-img.conf';
  22.  
  23. my $modules_base    = '/lib/modules';
  24.  
  25. die "Pre inst Internal error. Aborting." unless $version;
  26.  
  27. exit 0 if $ARGV[0] =~ /abort-upgrade/;
  28. exit 1 unless $ARGV[0] =~ /(install|upgrade)/;
  29.  
  30. if (-r "$CONF_LOC" && -f "$CONF_LOC"  ) {
  31.   if (open(CONF, "$CONF_LOC")) {
  32.     while (<CONF>) {
  33.       chomp;
  34.       s/\#.*$//g;
  35.       next if /^\s*$/;
  36.  
  37.       $preinst_hook    = "$1"  if /preinst_hook\s*=\s*(\S+)/i;
  38.     }
  39.     close CONF;
  40.   }
  41. }
  42.  
  43. $ENV{KERNEL_ARCH}=$kernel_arch if $kernel_arch;
  44.  
  45.  
  46. # set the env var stem
  47. $ENV{'STEM'} = "linux";
  48.  
  49. sub exec_script {
  50.   my $type   = shift;
  51.   my $script = shift;
  52.   print STDERR "Running $type hook script $script.\n";
  53.   system ("$script $version $realimageloc$kimage-$version") &&
  54.     print STDERR "User $type hook script [$script] ";
  55.   if ($?) {
  56.     if ($? == -1) {
  57.       print STDERR "failed to execute: $!\n";
  58.     }
  59.     elsif ($? & 127) {
  60.       printf STDERR "died with signal %d, %s coredump\n",
  61.         ($? & 127),  ($? & 128) ? 'with' : 'without';
  62.     }
  63.     else {
  64.       printf STDERR "exited with value %d\n", $? >> 8;
  65.     }
  66.     exit $? >> 8;
  67.   }
  68. }
  69. sub run_hook {
  70.   my $type   = shift;
  71.   my $script = shift;
  72.   if ($script =~ m,^/,) {
  73.     # Full path provided for the hook script
  74.     if (-x "$script") {
  75.       &exec_script($type,$script);
  76.     }
  77.     else {
  78.       die "The provided $type hook script [$script] could not be run.\n";
  79.     }
  80.   }
  81.   else {
  82.     # Look for it in a safe path
  83.     for my $path ('/bin', '/sbin', '/usr/bin', '/usr/sbin') {
  84.       if (-x "$path/$script") {
  85.         &exec_script($type, "$path/$script");
  86.         return 0;
  87.       }
  88.     }
  89.     # No luck
  90.     print STDERR "Could not find $type hook script [$script].\n";
  91.     die "Looked in: '/bin', '/sbin', '/usr/bin', '/usr/sbin'\n";
  92.   }
  93. }
  94.  
  95.  
  96. my $options;
  97. for (@ARGV) {
  98.     s,','\\'',g;
  99.     $options .= " '$_'";
  100. }
  101. $ENV{'DEB_MAINT_PARAMS'}="$options";
  102.  
  103. ## Run user hook script here, if any
  104. if (-x "$preinst_hook") {
  105.   &run_hook("preinst", $preinst_hook);
  106. }
  107. if (-d "/etc/kernel/preinst.d") {
  108.   print STDERR "Examining /etc/kernel/preinst.d/\n";
  109.   system ("run-parts --verbose --exit-on-error --arg=$version" .
  110.           " --arg=$realimageloc$kimage-$version" .
  111.           " /etc/kernel/preinst.d") &&
  112.             die "Failed to process /etc/kernel/preinst.d";
  113. }
  114. if (-d "/etc/kernel/preinst.d/$version") {
  115.   print STDERR "Examining /etc/kernel/preinst.d/$version.\n";
  116.   system ("run-parts --verbose --exit-on-error --arg=$version" .
  117.           " --arg=$realimageloc$kimage-$version" .
  118.           " /etc/kernel/preinst.d/$version") &&
  119.             die "Failed to process /etc/kernel/preinst.d/$version";
  120. }
  121.  
  122. exit 0;
  123.  
  124. __END__
  125.